x  = 2*randn(1,500);     % Input to the filter 
b  = fir1(31,0.5);     % FIR system to be identified 
n  = 0.1*randn(1,500); % Observation noise signal 
d  = filter(b,1,x)+n;  % Desired signal 
mu = 0.008;            % LMS step size. 
ha = adaptfilt.lms(32,mu); 
[y,e] = filter(ha,x,d); 
subplot(2,1,1); plot(1:500,[d;y;e]); 
title('System Identification of an FIR Filter'); 
legend('Desired','Output','Error'); 
xlabel('Time Index'); ylabel('Signal Value'); 
subplot(2,1,2); stem([b.',ha.coefficients.']); 
legend('Actual','Estimated'); 
xlabel('Coefficient #'); ylabel('Coefficient Value');  grid on;